#ifndef DEFECTDETECTION_H
#define DEFECTDETECTION_H
#pragma once

#include"inference.h"
#include "utils.h"
#include"GdalOpencvTensor.h"
#include "GeologicalHazard.h"
#include "BuildingExtractor.h" 
#include "qstring.h"
#include "qdir.h"
#include "qdatetime.h"
#include "SamOnnxRunner.h"
#include "RoadRepairer.h"

class DefectDetection
{
public:
	DefectDetection();
	DefectDetection(string modelPath, int modelType,bool useBoxInfo, bool usePointInfo, string saveDir );
	~DefectDetection();
public:
	bool YoloDefectDetection(string modelPath, string inputFileName, string saveFileName, vector<std::string> classes_Names, std::vector<int> classes_Ids, vector<string> classes_filters, vector<int> ids_filters);
	bool SegModel(string modelPath, string inputFileName, string saveFileName,int iflag);
	bool BuildingExtraction(string modelPath, string inputFileName, string saveFileName, string tmpPath="");
	bool SAMByShp(string tifPath, string shpPath, string savePath);
	bool RoadRepair(string modelPath, string inputFileName, string maskFileName, string saveFileName, double buffer_distance = 0.00);

private:
	SAMOnnxRunner* samOnnxRunner = nullptr;
	Configuration* cfg = nullptr;
	QStringList GetImages(QString file_path);
	cv::Mat padImage(const cv::Mat& input, int targetSize = 1024);
	int checkAndProcessImage(const string& imagePath);
	//bool processA();
	//bool processB();
};
#endif 